package 剑指offer;

/**
 *  和为s的两个数字
 */
public class Offer57_JZ42 {
    public int[] twoSum(int[] nums, int target) {
        int i=0, j = nums.length-1;
        while(i <= j) {
            if (nums[i]+nums[j] == target) {
                return new int[]{nums[i], nums[j]};
            } else if (nums[i]+nums[j] > target) {
                j-=1;
            } else if (nums[i]+nums[j] < target) {
                i+=1;
            }
        }
        return new int[0];
    }
}
